﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;

namespace BGCMS.Models
{
    /// <summary>
    /// Class provides current userID, used for unit testing purposes
    /// </summary>
    public class UserProvider : IUserProvider
    {
        public Guid GetCurrentUserId()
        {
            MembershipUser user = Membership.GetUser(HttpContext.Current.User.Identity.Name);
            if (user == null)
            {
                throw new InvalidOperationException("Notandinn " + HttpContext.Current.User.Identity.Name + "finnst ekki");
            }

            return (Guid)user.ProviderUserKey;
        }
    }
}